package com.jambo.yudada.scoring;

import com.jambo.yudada.common.ErrorCode;
import com.jambo.yudada.exception.BusinessException;
import com.jambo.yudada.model.entity.App;
import com.jambo.yudada.model.entity.UserAnswer;
import com.jambo.yudada.model.enums.AppScoringStragetyEnum;
import com.jambo.yudada.model.enums.AppTypeEnum;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@Deprecated
public class ScoringStrategyContext {
    @Resource
    private CustomTestScoringStrategy customTestScoringStrategy;
    @Resource
    private CustomScoreScoringStrategy customScoringStrategy;
    /**
     * 评分
     */
    public UserAnswer doScore(List<String> choiceList, App app)throws Exception{
        AppTypeEnum appTypeEnum=AppTypeEnum.getEnumByValue(app.getAppType());
        AppScoringStragetyEnum appScoringStragetyEnum=AppScoringStragetyEnum.getEnumByValue(app.getScoringStrategy());
        if(appTypeEnum==null||appScoringStragetyEnum==null){
            throw new BusinessException(ErrorCode.SYSTEM_ERROR,"应用配置有误，未找到匹配的策略");
        }
        switch(appTypeEnum){
            case SCORE:
             switch(appScoringStragetyEnum){
                 case CUSTOM:
                     return customScoringStrategy.doScore(choiceList,app);
                 case DeepSeek:
                     break;
             }
             case TEST:
                 switch(appScoringStragetyEnum){
                     case CUSTOM:
                         return customTestScoringStrategy.doScore(choiceList,app);
                     case DeepSeek:
                      break;
                 }
        }
        throw new BusinessException(ErrorCode.SYSTEM_ERROR,"应用配置有误，未找到匹配的策略");
    }
}
